<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('order_id')->comment('订单号');
            $table->unsignedBigInteger('product_id')->comment('产品ID');
            $table->tinyInteger('expire')->default(0)->comment('过期类型');
            $table->tinyInteger('attribute')->default(0)->comment('良品类型');
            $table->date('expiry')->nullable()->comment('最小失效日期');
            $table->integer('quantity')->comment('数量');
            $table->double('price', 19, 5)->comment('单价');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_products');
    }
}
